using UnityEngine;
using System.Collections;
using System;

namespace Flaschengeist.Processes 
{
	public class CalculateRemainingFluid
	{
		private float startFillLevel;
		private float endFillLevel;
		private int totalFluid;
				
		public void SetStartFillLevel(float startFillLevel)
		{
			this.startFillLevel = startFillLevel;
		}
						
		public void SetEndFillLevel(float endFillLevel)
		{
			this.endFillLevel = endFillLevel;
		}
		
		public void SetTotalFluid(int totalFluid)
		{
			this.totalFluid = totalFluid;
		}
		
		public void Process()
		{
			var diff = endFillLevel - startFillLevel;
			if ((totalFluid - diff) > 0)
				totalFluid = (int)(totalFluid - diff);
			else
				totalFluid = 0;	
			
			Completed(totalFluid);
		}
		
		public event Action<int> Completed;
	}
}

